#if defined(ORATR_USE_HTTP)

#ifndef _WIN_TCPSOCKET_H_INCLUDED_
#define _WIN_TCPSOCKET_H_INCLUDED_

#include "os.hpp"
#if defined(USING_WINDOWS)
	#include <winsock2.h>
	typedef int socklen_t;
#elif defined(USING_LINUX)
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <arpa/inet.h>
	#include <netdb.h>
	#include <cstring>
	typedef unsigned long DWORD;
	typedef sockaddr_in SOCKADDR_IN;
	typedef int SOCKET;
	#define INVALID_SOCKET -1
	#define SOCKET_ERROR -1
#endif

class CWinTcpSocket
{
public:
	CWinTcpSocket( void );
	virtual ~CWinTcpSocket( void );

	virtual bool Create( int af = AF_INET );
	virtual bool Connect( const char *pszHost, int nPort );
	virtual bool Bind( int nLocalPort );
	virtual bool Accept( CWinTcpSocket *pSocket );
	virtual bool Listen( int nBacklog = SOMAXCONN );
	virtual int Send( const void *pData, int nDataLen, int nFlags = 0 );
	virtual int SendText( const char *pszText );
	virtual int Recv( void *pData, int nDataLen, int nFlags = 0 );
	virtual int RecvLine( char *pszBuf, int nLen, bool bEcho = false );
	virtual bool Shutdown( int nHow );
	virtual bool Close( void );

	SOCKET m_hSocket;

private:
	static DWORD m_dwRefCount;
};

#endif
#endif
